package com.quanyan.authority.serviceFacade;

import com.quanyan.api.APIResponse;
import com.quanyan.authority.service.AdminUserService;
import com.quanyan.user.request.ReqAdminUser;
import com.quanyan.user.serviceFacade.AdminUserServiceFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by Administrator on 2016/8/29.
 */
public class AdminUserServiceFacadeImpl implements AdminUserServiceFacade {

    private static final Logger logger = LoggerFactory.getLogger(AdminUserServiceFacadeImpl.class);

    @Autowired
    private AdminUserService adminUserService;

    @Override
    public APIResponse addAdminUser(ReqAdminUser reqAdminUser) {
        try {
            com.quanyan.authority.model.request.ReqAdminUser r = new com.quanyan.authority.model.request.ReqAdminUser();
            BeanUtils.copyProperties(reqAdminUser,r);
            return APIResponse.returnSuccess( adminUserService.add(r));
        } catch (BeansException e) {
            logger.error("{}",e);
            return APIResponse.returnFail("系统异常！");
        }
    }
}
